(define (make-queue)
  (let ((front-ptr '())
        (rear-ptr '()))
    (define (empty-queue?) (null? front-ptr))
    (define (set-front-ptr! x) (set! front-ptr x))
    (define (set-rear-ptr! x) (set! rear-ptr x))
    (define (front-queue)
      (if (empty-queue?)
        (error "empty queue!")
        (car front-ptr)))
    (define (insert-queue x)
      (let ((new-pair (cons x '())))
       (cond ((empty-queue?)
              (begin
                (set-front-ptr! new-pair)
                (set-rear-ptr! new-pair) ))
             (else
               (begin 
                 (set-cdr! rear-ptr new-pair)
                 (set-rear-ptr! new-pair))))))
    (define (delete-queue)
      (if (empty-queue?)
        (error "empty queue!")
        (begin
          (set-front-ptr! (cdr front-ptr)))))
    (define (print-queue) front-ptr)
    (define (dispatch m)
      (cond ((eq? m 'empty-queue) empty-queue?) 
            ((eq? m 'front-queue) front-queue)
            ((eq? m 'insert) insert-queue)
            ((eq? m 'delete) delete-queue)
            ((eq? m 'print) print-queue)
            (else (error "error"))))
    dispatch))
